package com.example.shotscreen;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

/**
 * Created by Alex-Zhang on 2017/10/31.
 */

public class MyRadioButton extends android.support.v7.widget.AppCompatRadioButton {

    private Drawable mDrawable;

    public MyRadioButton(Context context) {
        this(context, null);
    }

    public MyRadioButton(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MyRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mDrawable = context.getResources().getDrawable(R.drawable.indicator);


    }


    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        final int intrinsicWidth = mDrawable.getIntrinsicWidth();
        final int intrinsicHeight = mDrawable.getIntrinsicHeight();


        mDrawable.setBounds(new Rect(0,40,50 ,50));
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        mDrawable.draw(canvas);
    }
}
